<!DOCTYPE html>
<html>
    <head>
        <title>小海博客</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!-- Bootstrap -->
        <!--        <link href="/common/css/bootstrap.min.css" rel="stylesheet" media="screen">-->
        <link href="<?php echo base_url(); ?>common/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="<?php echo base_url(); ?>common/css/signin.css" rel="stylesheet" media="screen">
        <!--<link href="/common/css/signin.css" rel="stylesheet" media="screen">-->
        <script src="http://code.jquery.com/jquery.js"></script>
        <script src="<?php echo base_url(); ?>common/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <form class="form-signin">
                <h2 class="form-signin-heading">登录</h2>
                <label for="inputEmail" class="sr-only">用户名</label>
                <input type="text" id="username" class="form-control" placeholder="用户名" required autofocus>
                <label for="inputPassword" class="sr-only">密码</label>
                <input type="password" id="password" class="form-control" placeholder="密码" required>
                <div class="text-danger login-null" style="display:none">请填入用户名和密码.</div>
                <div class="text-danger login-fail" style="display:none">用户不存在或密码错误.</div>
                <div class="btn btn-lg btn-primary btn-block"  id="submit_button">登录</div>
            </form>

        </div> <!-- /container -->
        <script>
            $('#submit_button').bind('click', function () {
                $('.login-null').hide();
                var username = $("#username").val();
                var password = $("#password").val();
                if (username != "" && password != "") {
                    $.ajax({
                        url: '<?php echo site_url(); ?>/OceanBlog/LoginPage/checkLogin',
                        type: 'POST',
                        data: {
                            username: username,
                            password: password
                        },
                        success: function () {
                            window.location.href='<?php echo site_url(); ?>/OceanBlog/MainPage';
                        },
                        error: function () {
                            $('.login-fail').show();
                        }
                    });

                }else{
                    $('.login-null').show();
                }
            });
        </script>

    </body>
</html>